home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / dnet / drexxmail.lha / mail.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1994-10-01  |  2.6 KB  |  100 lines

  1. /* Mail.rexx  v1.00  - by Rick Taylor, 9-26-94 */
  2. /* v1.01 - 9-30-94 */
  3. /* v1.02 - 10-1-94 */
  4. options results
  5. address command
  6.  
  7. /* Some initializations... */
  8.  
  9. lf = '0a'x
  10. cr = '0d'x
  11. MailFile = ""
  12. CodeFlag = ""
  13. passed = ARG(1)
  14. parse var passed whoto MailFile CodeFlag . rest .
  15. if MailFile = "" then CodeFlag = ""
  16.  
  17. if whoto = "" then do
  18.      say "USAGE:  First alias MAIL rx drexxmail:mail.rexx"
  19.      say "        Then use the following template..."
  20.      say " "
  21.      say "MAIL <user@host[,user@host,user@host,...]> [<filename>] [u]"
  22.      say " "
  23.      exit
  24.      end
  25.  
  26. if exists('T:mailrexx.mail') then 'delete T:mailrexx.mail QUIET'
  27.  
  28. /* Prepare the mail file */
  29.  
  30. if MailFile ~= "" then do
  31.      'copy' MailFile "T:mailrexx.mail QUIET"
  32.      if CodeFlag = "u" then do 
  33.           call open ecommand, "T:mailrexx.cmd",write
  34.           call writeln ecommand, 'uuxt <NIL: >NIL: a t:mailrexx.mail 'MailFile
  35.           call close ecommand
  36.           'execute' "T:mailrexx.cmd"
  37.           say "Sending binary file UUencoded..."
  38.           end
  39.           else say "Sending plain text file..."         
  40.      end
  41.      else do
  42.      say "Type your message below.  Use a single period on a line by" 
  43.      say "itself to end the message."
  44.      say "----------------------------------------------------------"
  45.      say " "
  46.      call open mf, "T:mailrexx.mail",write
  47.      msglin = ""
  48.      do until msglin = "."
  49.           call writeln mf,msglin
  50.           parse pull msglin
  51.           end
  52.      call close mf
  53.      end
  54.      
  55. /* Subject? */
  56.  
  57. if CodeFlag = "u" then mailsub = "UUencoded file - "||MailFile
  58.      else do
  59.           say "Enter a subject for this mail:"
  60.           parse pull mailsub
  61.      end 
  62. if mailsub = "" then mailsub = "No subject given - plain text message"
  63.  
  64. /* We need to make a mail file with headers + signature for sendmail.rexx */
  65.  
  66. call open hdr,"T:mailrexx.hdr",write
  67. call writeln hdr, 'To: ' whoto
  68. call writeln hdr, 'Subject:' mailsub
  69. call writeln hdr, 'X-Mailer: DREXXMAIL Mailer CLI Version 1.02 (October 1 1994)'
  70. call close hdr
  71.  
  72. sigfile = ""
  73. if CodeFlag ~= "u" then sigfile = envar('DRMSIGNATURE')
  74.  
  75. 'join T:mailrexx.hdr T:mailrexx.mail' sigfile 'AS T:mmessage'
  76. 'delete T:mailrexx.hdr QUIET'
  77. 'delete T:mailrexx.mail QUIET'
  78.  
  79. /* Mail file is made, so let's send the message with sendmail.rexx */
  80. say "Sending..."
  81. 'rx drexxmail:sendmail.rexx t:mmessage'
  82. 'delete T:mmessage QUIET'
  83.  
  84. /* We're outta here */
  85.  
  86. msg = "Sent!"||lf||"To: "||whoto||lf||"Subject: "||mailsub||lf
  87. say msg
  88. exit
  89.  
  90. envar: procedure
  91.      arg evname
  92.      epath = "ENV:"||evname
  93.      evalue = ""
  94.      if exists(epath) then do
  95.           call open .envar,epath,read
  96.           evalue = readln(.envar)
  97.           call close .envar
  98.           end
  99.      return evalue
  100.